-
Notifications
You must be signed in to change notification settings - Fork 122
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(tooltip): add boundary padding #1065
fix(tooltip): add boundary padding #1065
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, I have tested it locally and works fine.
api/charts.api.md
Outdated
@@ -2221,6 +2221,8 @@ export interface TooltipInfo { | |||
// @public | |||
export interface TooltipPortalSettings<B = never> { | |||
boundary?: HTMLElement | B; | |||
// Warning: (ae-forgotten-export) The symbol "Padding" needs to be exported by the entry point index.d.ts |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you want to expose also the Padding
type?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea 8d9f3f6
@@ -138,7 +154,7 @@ const TooltipPortalComponent = ({ | |||
boundary, | |||
// checks main axis overflow before trying to flip | |||
altAxis: false, | |||
padding: offset || 10, | |||
padding: addToPadding(boundaryPadding, offset || 10), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
with that offset || 10
are we saying that we always want a padding of 10 and the user cannot set 0 here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure why I had 10
there. Maybe just to flip away 10px
from the edge.
Anyways I removed this and only add the offset
value. See 8d9f3f6
Codecov Report
@@ Coverage Diff @@
## master #1065 +/- ##
==========================================
+ Coverage 72.47% 72.86% +0.39%
==========================================
Files 366 382 +16
Lines 11361 11672 +311
Branches 2472 2523 +51
==========================================
+ Hits 8234 8505 +271
- Misses 3112 3144 +32
- Partials 15 23 +8
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
# Conflicts: # api/charts.api.md # src/index.ts
🎉 This PR is included in version 25.2.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
@@ -56,6 +57,20 @@ type PortalTooltipProps = { | |||
chartId: string; | |||
}; | |||
|
|||
function addToPadding(padding?: Partial<Padding> | number, extra: number = 0): Padding | number | undefined { | |||
if (!padding) return undefined; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if padding
is 0, is it OK to return undefined?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point, I don't think this is critical but it should return just the extra
value when/if padding
is undefined
. I'll open a pr.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# [25.2.0](elastic/elastic-charts@v25.1.1...v25.2.0) (2021-03-09) ### Bug Fixes * **tooltip:** add boundary padding ([opensearch-project#1065](elastic/elastic-charts#1065)) ([5606eba](elastic/elastic-charts@5606eba)) ### Features * **partition:** flame and icicle performance and tweening ([opensearch-project#1041](elastic/elastic-charts#1041)) ([2ac7550](elastic/elastic-charts@2ac7550))
Summary
closes #1062
Adds an artificial
padding
around the specifiedboundary
element to contain tooltip within boundaries with top margins.Screen.Recording.2021-03-09.at.09.06.08.AM.mp4
Checklist
src/index.ts
(and stories only import from../src
except for test data & storybook)